import { validPhoneReg } from "@/utils/validate";
import { BILL_TYPE_1 } from "@/config/enum"
export const modalFormConfig = {
  labelWidth: "100px",
  itemLayout: {
    padding: "10px 40px",
  },
  colLayout: { span: 24 },
  alwaysShow: true,
  formItems: [
    {
      field: "name",
      type: "input",
      label: "用户名",
      placeholder: "请输入用户名",
      rules: [{ required: true, message: "请输入用户名", trigger: "blur" }],
    },
    {
      field: "phone",
      type: "number",
      label: "电话号码",
      placeholder: "请输入电话号码",
      rules: [
        { required: true, message: "请输入电话号码", trigger: "blur" },
        { pattern: validPhoneReg, message: "请输入正确的电话号码", trigger: "blur" },
      ],
    },
    {
      field: 'roleIds',
      type: 'select',
      label: '选择角色',
      placeholder: '请选择角色',
      // rules: [{ required: true, message: '请选择角色', trigger: 'blur' }],
      options: [],
      otherOptions: {
        multiple: true
      }
    },
    {
      field: 'gradeLevel',
      type: 'select',
      label: '选择等级',
      placeholder: '请选择等级',
      rules: [{ required: true, message: '请选择等级', trigger: 'blur' }],
      options: []
    },
    {
      field: 'billType',
      type: 'select',
      label: '结算类型',
      placeholder: '请选择结算类型',
      rules: [{ required: true, message: '请选择结算类型', trigger: 'blur' }],
      options: BILL_TYPE_1
    },
    {
      field: 'order',
      type: 'number',
      label: '排序码',
      placeholder: '请输入排序码',
      rules: [
        { 
          required: true, 
          message: '排序码不能为空', 
          trigger: 'blur' 
        },
        {
          validator: (rule, value, callback) => {
            if (value > 100) {
              callback(new Error('排序码不能超过 100'));
            } else {
              callback();
            }
          },
          trigger: 'blur'
        }
      ],
      otherOptions: {
        type: "number",
      }
    },
  ],
};
